<?php

namespace App\Http\Requests;

use Illuminate\Foundation\Http\FormRequest;

class ArticleCategory extends FormRequest
{
    /**
     * Determine if the user is authorized to make this request.
     *
     * @return bool
     */
    public function authorize()
    {
        return true;
    }

    /**
     * Get the validation rules that apply to the request.
     *
     * @return array
     */
    public function rules()
    {
        return [
            'cate_name'=>'required|regex:/^[\x{4e00}-\x{9fa5}]+$/u|between:2,10',
            'cate_pinyin' => 'required|alpha|between:2,100',
            'cate_sort' => 'integer',
            'cate_status' => 'required|in:1,2',
        ];
    }

    public function messages(): array
    {
        return [
            'cate_name.required' => '分类名不能为空',
            'cate_name.regex' => '分类名只能由汉字组成',
            'cate_name.min' => '分类名的长度为2-10个字符',

            'cate_pinyin.required' => '分类名拼音不能为空',
            'cate_pinyin.alpha' => '分类名拼音只能由为字母组成',
            'cate_pinyin.min' => '分类名拼音长度为2-100个字符',

            'cate_status.required' => '状态不能为空',
            'cate_status.in' => '状态值只能是1或者2',

            'cate_sort.integer' => '排序值必须是整数',
        ];
    }
}
